import {
  getBuildConfig,
  cjsCompatPlugin,
  lcSecretsPlugin,
  importMapPlugin,
  importConstantsPlugin,
} from "@langchain/build";

export default getBuildConfig({
  entry: [
    "./src/index.ts",
    "./src/load/index.ts",
    "./src/load/serializable.ts",
    "./src/agents/index.ts",
    "./src/agents/load.ts",
    "./src/agents/toolkits/index.ts",
    "./src/agents/toolkits/sql/index.ts",
    "./src/agents/format_scratchpad/openai_functions.ts",
    "./src/agents/format_scratchpad/openai_tools.ts",
    "./src/agents/format_scratchpad/log.ts",
    "./src/agents/format_scratchpad/xml.ts",
    "./src/agents/format_scratchpad/log_to_message.ts",
    "./src/agents/react/output_parser.ts",
    "./src/agents/xml/output_parser.ts",
    "./src/agents/openai/output_parser.ts",
    "./src/tools/index.ts",
    "./src/tools/chain.ts",
    "./src/tools/render.ts",
    "./src/tools/retriever.ts",
    "./src/tools/sql.ts",
    "./src/tools/webbrowser.ts",
    "./src/chains/index.ts",
    "./src/chains/combine_documents/index.ts",
    "./src/chains/combine_documents/reduce.ts",
    "./src/chains/history_aware_retriever.ts",
    "./src/chains/load.ts",
    "./src/chains/openai_functions/index.ts",
    "./src/chains/query_constructor/index.ts",
    "./src/chains/query_constructor/ir.ts",
    "./src/chains/retrieval.ts",
    "./src/chains/sql_db/index.ts",
    "./src/chains/graph_qa/cypher.ts",
    "./src/chat_models/universal.ts",
    "./src/embeddings/cache_backed.ts",
    "./src/embeddings/fake.ts",
    "./src/vectorstores/memory.ts",
    "./src/text_splitter.ts",
    "./src/memory/index.ts",
    "./src/memory/chat_memory.ts",
    "./src/document.ts",
    "./src/document_loaders/base.ts",
    "./src/document_loaders/fs/buffer.ts",
    "./src/document_loaders/fs/directory.ts",
    "./src/document_loaders/fs/json.ts",
    "./src/document_loaders/fs/multi_file.ts",
    "./src/document_loaders/fs/text.ts",
    "./src/document_transformers/openai_functions.ts",
    "./src/sql_db.ts",
    "./src/callbacks/index.ts",
    "./src/output_parsers/index.ts",
    "./src/output_parsers/expression.ts",
    "./src/retrievers/contextual_compression.ts",
    "./src/retrievers/document_compressors/index.ts",
    "./src/retrievers/ensemble.ts",
    "./src/retrievers/multi_query.ts",
    "./src/retrievers/multi_vector.ts",
    "./src/retrievers/parent_document.ts",
    "./src/retrievers/time_weighted.ts",
    "./src/retrievers/document_compressors/chain_extract.ts",
    "./src/retrievers/document_compressors/embeddings_filter.ts",
    "./src/retrievers/hyde.ts",
    "./src/retrievers/score_threshold.ts",
    "./src/retrievers/self_query/index.ts",
    "./src/retrievers/self_query/functional.ts",
    "./src/retrievers/matryoshka_retriever.ts",
    "./src/cache/file_system.ts",
    "./src/stores/doc/base.ts",
    "./src/stores/doc/in_memory.ts",
    "./src/stores/file/in_memory.ts",
    "./src/stores/file/node.ts",
    "./src/stores/message/in_memory.ts",
    "./src/storage/encoder_backed.ts",
    "./src/storage/in_memory.ts",
    "./src/storage/file_system.ts",
    "./src/hub/index.ts",
    "./src/hub/node.ts",
    "./src/util/document.ts",
    "./src/util/math.ts",
    "./src/util/time.ts",
    "./src/experimental/autogpt/index.ts",
    "./src/experimental/openai_assistant/index.ts",
    "./src/experimental/openai_files/index.ts",
    "./src/experimental/babyagi/index.ts",
    "./src/experimental/generative_agents/index.ts",
    "./src/experimental/plan_and_execute/index.ts",
    "./src/experimental/chains/violation_of_expectations/index.ts",
    "./src/experimental/masking/index.ts",
    "./src/experimental/prompts/custom_format.ts",
    "./src/experimental/prompts/handlebars.ts",
    "./src/evaluation/index.ts",
    "./src/smith/index.ts",
    "./src/indexes/index.ts",
    "./src/schema/query_constructor.ts",
    "./src/schema/prompt_template.ts",
  ],
  plugins: [
    cjsCompatPlugin({
      files: ["dist/", "CHANGELOG.md", "README.md", "LICENSE"],
    }),
    lcSecretsPlugin(),
    importMapPlugin({
      omitFromImportMap: ["hub/index", "hub/node", "load/index"],
      extraEntries: [
        {
          modules: ["StringOutputParser"],
          alias: ["schema", "output_parser"],
          path: "@langchain/core/output_parsers",
        },
      ],
    }),
    importConstantsPlugin({
      entrypoints: [
        "agents/load",
        "agents/toolkits/sql",
        "tools/sql",
        "tools/webbrowser",
        "chains/load",
        "chains/query_constructor",
        "chains/query_constructor/ir",
        "chains/sql_db",
        "chains/graph_qa/cypher",
        "chat_models/universal",
        "document_loaders/fs/buffer",
        "document_loaders/fs/directory",
        "document_loaders/fs/json",
        "document_loaders/fs/multi_file",
        "document_loaders/fs/text",
        "sql_db",
        "output_parsers/expression",
        "retrievers/self_query",
        "retrievers/self_query/functional",
        "cache/file_system",
        "stores/file/node",
        "storage/file_system",
        "hub",
        "hub/node",
      ],
    }),
  ],
});
